<include file="__PUBLIC__/_header"/>
<body>
<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try {
            ace.settings.check('navbar', 'fixed')
        } catch (e) {
        }
    </script>
    <include file="__PUBLIC__/_header_title"/><!-- /.container -->
</div>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>
        <div class="sidebar" id="sidebar">
            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'fixed')
                } catch (e) {
                }
            </script>
            <include file="__PUBLIC__/_nav"/>
            <div class="sidebar-collapse" id="sidebar-collapse">
                <i class="icon-double-angle-left" data-icon1="icon-double-angle-left"
                   data-icon2="icon-double-angle-right"></i>
            </div>
            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'collapsed')
                } catch (e) {
                }
            </script>
        </div>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try {
                        ace.settings.check('breadcrumbs', 'fixed')
                    } catch (e) {

                    }
                </script>

                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href="{:Controller::_createUrl('index/index')}">首页</a>
                    </li>

                    <li class="active"> 用户管理</li>
                    <li class="active"> 用户列表</li>
                </ul><!-- .breadcrumb -->
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="tabbable">
                            <div class="tab-content no-border padding-24">
                                <div id="faq-tab-1" class="tab-pane fade in active">
                                    <div id="faq-list-1" class="panel-group accordion-style1 accordion-style2">
                                        <div class="panel panel-default">
                                            <form id="search-box" data-id="12ea1025df5187e3afb9b39f4437f308" class="form-horizontal form-actions" action="{:Controller::_createUrl('user/userlist',$_GET)}" method="get" style="padding-left: 0px; margin-top: 40px;">
                                                <div id="myTabContent" class="tab-content" style="margin:0 10px 10px 10px;padding: 10px;">
                                                    <div class="tab-pane fade in active" id="filter">
                                                        <ul>
                                                            <li class="pull-left link-item col-xs-6 col-sm-12 text-left " style="list-style: none">
                                                                <div class="pull-left col-xs-1  col-sm-2">
                                                                    <label for="account_name">账号名称</label>
                                                                </div>
                                                                <div class=" pull-left text-left col-xs-2  col-sm-6">
                                                                    <div class="input-group">
                                                                        <span class="input-group-addon icon-font"></span>
                                                                        <input type="text" class="text-center field-edit type4" placeholder="" data-m="" data-id="" name="account_name" id="account_name" value="{$_GET['account_name']}" />
                                                                    </div>
                                                                </div> </li>
                                                            <div class="row" style="margin-left: 30px;padding-top: 20px;">
                                                                <button style="margin-top: 20px;" type="submit" class="btn btn-success icon-search">查询</button>
                                                                <button style="margin-top: 20px;" type="reset" class="btn btn-refresh icon-refresh">清除</button>
                                                            </div>
                                                        </ul>
                                                    </div>
                                                </div>
                                                <input type="hidden" name="search" value="1" />
                                            </form>
                                            <table id="sample-table-1"
                                                   class="table table-striped table-bordered table-hover">
                                                <thead>
                                                <tr>
                                                    <th>用户编号</th>
                                                    <th>用户账号</th>
                                                    <!--<th>真实姓名</th>-->
                                                    <th>会员类型</th>
                                                    <th>登录帐号</th>
                                                    <!--<th>性别</th>-->
                                                    <!--<th>年龄</th>-->
                                                    <!--<th>邮箱</th>-->
                                                    <!--<th>QQ号码</th>-->
                                                    <!--<th>创建时间</th>-->
                                                    <!--<th>用户标签</th>-->
                                                    <!--<th>用户统计</th>-->
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <volist name="list" id="vo">
                                                    <tr>
                                                        <td style="vertical-align: middle;">{$vo.user_id}</td>
                                                        <td style="vertical-align: middle;">{$vo.user_name}</td>
                                                        <!--<td style="vertical-align: middle;"><span>{$vo.real_name}</span>&nbsp;<i-->
                                                                <!--class="blue real_name icon-edit"-->
                                                                <!--ids="{$vo.user_id}"></i></td>-->
                                                        <td style="vertical-align: middle;">{$vo.type_name}</td>
                                                        <td style="vertical-align: middle;">{$vo.mobile}</td>
                                                        <!--<td style="vertical-align: middle;">{$vo.gender_name}</td>-->
                                                        <!--<td style="vertical-align: middle;">{$vo.age}</td>-->
                                                        <!--<td style="vertical-align: middle;">{$vo.email}</td>-->
                                                        <!--<td style="vertical-align: middle;">{$vo.qq}</td>-->
                                                        <!--<td style="vertical-align: middle;">{$vo.create_time}</td>-->
                                                        <!--<td style="vertical-align: middle;">-->
                                                            <!--<if condition="$vo['tag_name'] == ''">-->
                                                                <!--<div class="open_add_tag tags_" ids="{$vo.user_id}">-->
                                                                    <!--添加-->
                                                                <!--</div>-->
                                                                <!--<else/>-->
                                                                <!--{$vo['tag_name']}&nbsp;&nbsp;&nbsp;&nbsp;<i-->
                                                                    <!--class="icon-edit edit_tag blue open_add_tag"-->
                                                                    <!--title="修改"-->
                                                                    <!--ids="{$vo.user_id}"></i>-->
                                                            <!--</if>-->
                                                        <!--</td>-->
                                                        <!--<td style="vertical-align: middle;"><a class="iframe"-->
                                                                                               <!--href="{:Controller::_createUrl('user/userStatistics',array('user_id'=>$vo['user_id']))}">查看</a>-->
                                                        <!--</td>-->
                                                        <td style="vertical-align: middle;">
                                                            <div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                                                                <a class="iframe"
                                                                   href="{:Controller::_createUrl('user/passwordSet',array('id'=>$vo['user_id']))}">
                                                                    <button class="btn btn-xs btn-info">
                                                                        <i class="icon-edit bigger-120"></i>
                                                                    </button>
                                                                </a>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </volist>
                                                <tr>
                                                    <td colspan="13">
                                                        <ul class="pagination" style="float: right">
                                                            {$pager_html}
                                                        </ul>
                                                    </td>
                                                </tr>
                                                </tbody>
                                                <tfoot>
                                                </tfoot>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <script type="text/javascript">
                                var $path_base = "/";//this will be used in gritter alerts containing images
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    #dtree_div input[type="checkbox"] {
        margin: 10px 0 0;
        margin-top: 1px \9;
        line-height: normal;
    }

    .tags_ {
        color: #0a6999;
        cursor: pointer
    }

    .btn_tag {
        padding: 4px 12px !important;
    }
</style>
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
<input type="hidden" id="url_tag" value="{:Controller::_createUrl('user/getTagList')}">
<input type="hidden" id="edit_real_name_url" value="{:Controller::_createUrl('user/editRealName')}">
<link rel="stylesheet" type="text/css" href="__APP_SKIN__css/Popup.css"/>
<link rel="stylesheet" href="__APP_SKIN__css/dtree.css"/>
<input type="hidden" id="dir_img" value=>
<link href="__SKIN__/js/colorbox/colorbox.css" rel="stylesheet" type="text/css">
<script src="__SKIN__/js/colorbox/colorbox.js" type="text/javascript"></script>
<script src="__APP_SKIN__js/dtree.js"></script>
</body>
<script>
    $(function () {
        $(".iframe").colorbox({iframe:true, width:"50%", height:"60%"});
        var user_id = 0;
        var url = $('#url_tag').val();
        d = new dTree('d', true, '__APP_SKIN__images/');
        d.add(0, -1, '标签选择');
        $.ajax({
            type: "POST",
            async: false,
            dataType: "json",
            url: url,
            data: {'opt': 'tag_list'},
            success: function (data) {
                if (data.code == '200') {
                    var row = data.data;
                    for (var i in row) {
                        var parent_id = row[i].parent_id;
                        if (parent_id == null) parent_id = 0
                        d.add(row[i].kind_id, parent_id, 'kind_name', row[i].kind_name, row[i].kind_name, false);
                    }
                }
            }
        });
        tagAdd();

        function tagAdd() {
            $('#dtree_div').html(d.toString());
        }

        function editTag(data) {
            var arr = d.aNodes;
            for (var i in arr) {
                if ($.inArray(arr[i].cshow, data) >= 0) {
                    arr[i].cchecked = true;
                    if (arr[i].pid > 0) {
                        d.openTo(arr[i].pid);
                    }
                    $('#ulSelected').append('<li id="kind_' + arr[i].id + '">' + arr[i].cshow + '</li>')
                }
            }
            d.aNodes = arr;
            $('#dtree_div').html(d.toString());
            $('.bgPop,.pop').show();
        }

        $('.pop-close').click(function () {
            Close_dtree();
        });

        $('.bgPop').click(function () {
            Close_dtree();
        });
        var that = '';
        // 添加
        $('.tags_').click(function () {
            user_id = $(this).attr('ids');
            $('.bgPop,.pop').show();
            that = $(this)
        });

        // 修改
        icon_edit();

        function icon_edit() {
            $('.edit_tag').click(function () {
                user_id = $(this).attr('ids');
                that = $(this)
                $.ajax({
                    type: "POST",
                    async: false,
                    dataType: "json",
                    url: url,
                    data: {'opt': 'Tag', 'id': user_id},
                    success: function (data) {
                        if (data.code == '200') {
                            editTag(data.data);
                        } else {
                            $('.bgPop,.pop').show();
                        }
                    }
                });
            });
        }

        $('.btn-primary').click(function () {
            var str = '';
            $('#ulSelected li').each(function () {
                str += $(this).text() + ',';
            })
            str = str.substring(0, str.length - 1);
            if (str == '') {
                return false;
            }
            $.ajax({
                type: "POST",
                async: false,
                dataType: "json",
                url: url,
                data: {'id': user_id, 'str': str, 'opt': 'edit'},
                success: function (data) {
                    Close_dtree();
                    if (data.code == '200') {
                        that.parent().html(str + '&nbsp;&nbsp;&nbsp;&nbsp;<i class="icon-edit blue open_add_tag" title="修改" ids="' + user_id + '"></i>');
                        icon_edit();
                        bootbox.dialog({
                            message: "<span class='bigger-110'>" + data.msg + "</span>",
                            buttons: {
                                "success": {
                                    "label": "<i class='icon-ok'></i> Success!",
                                    "className": "btn-sm btn-success",
                                }
                            }
                        });
                    } else {
                        bootbox.dialog({
                            message: "<span class='btn-sm btn-danger'>" + data.msg + "</span>"
                        });
                    }
                }
            });
        })

        function Close_dtree() {
            $('.bgPop,.pop').hide();
            var arr = d.aNodes;
            for (var i in arr) {
                arr[i].cchecked = false;
            }
            d.aNodes = arr;
            $('#dtree_div').html(d.toString());
            d.openAll();
            $('#ulSelected').html('');
            $("[name='kind_name']").removeAttr("checked");
        }

        $(".iframe").colorbox({iframe: true, width: "90%", height: "90%"});

        // 修改用户真实姓名
        function real_name_click() {
            $('.real_name').dblclick(function () {
                var real_name = $(this).prev().text();
                var ids = $(this).attr('ids');
                $(this).parent().html('<input type="text" class="edit_real_name" ids="' + ids + '" value="' + real_name + '">');
                edit_real_name();
            })
        }

        real_name_click();
        function edit_real_name() {
            $('.edit_real_name').blur(function () {
                var url = $('#edit_real_name_url').val();
                var real_name = $(this).val();
                var user_id = $(this).attr('ids');
                var that = $(this);
                $.ajax({
                    type: "POST",
                    async: false,
                    dataType: "json",
                    url: url,
                    data: {'user_id': user_id, 'real_name': real_name},
                    success: function (data) {
                        if (data.code == '200') {
                            that.parent().html('<span>' + real_name + '</span>&nbsp;<i class="blue real_name icon-edit"></i>');
                            real_name_click();
                        }
                    }
                });
            })
        }
    })
</script>
</html>
